// pages/star/star.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    rating:9.5
  },

  onload:function(options){
    var num = this.data.rating;
    var stars = this.transformStar(num);
    this.setData({
      rating:stars
    })
  },
  transformStar(num){
    let arr = [];
    for(let i=0;i<5;i++){
      if(num>2){
        arr.push(2)
      }else if(num>0){
        arr.push(num)
      }else{
        arr.push(0)
      }
      num = num-2
    }
    return arr;
  }
})